package com.wc.alorithm_blue_bridge._动态规划.线性DP.括号序列;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/1/10 22:02
 * @description
 * https://www.lanqiao.cn/problems/1456/learning/?contest_id=74
 */
public class Main {
    /**
     * 思路：
     * 教学视频: https://www.acwing.com/video/2844/
     * 合法字符串 -> 不合法字符串 方案数  = 不合法字符串 -> 合法字符串 方案数
     * f[i][j] 表示前 i 个字符串 左括号比右括号多 j个的方案数
     * s[i] = '(',
     * f[i][j] = f[i - 1][j - 1]
     * s[i] = ')'
     * 前面添加 0 个左括号 f[i - 1][j + 1]
     * ...
     * 前面添加 j + 1 个左括号 f[i - 1][0]
     * f[i][j] = sum(f[i - 1][j + 1] + f[i - 1][j] + f[i - 1][j - 1] + ... + f[i - 1][0])
     * f[i][j - 1] = sum (f[i - 1][j] + ... + f[i - 1][0])
     * f[i][j] = f[i - 1][j + 1] + f[i - 1][j - 1]
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 5010, P = (int)1e9 + 7;
    static int[][] f = new int[N][N];
    static char[] s;
    static int n;

    public static void main(String[] args) {
        s = (" " + sc.next()).toCharArray();
        n = s.length - 1;
        int l = calc();
        for (int i = 1, j = n; i < j; i++, j--) {
            char tmp = s[i];
            s[i] = s[j];
            s[j] = tmp;
        }
        for (int i = 1; i <= n; i++) {
            if (s[i] == '(') s[i] = ')';
            else s[i] = '(';
        }
        int r = calc();
        out.println((long) l * r % P);
        out.flush();
    }

    static int calc() {
        for (int i = 0; i <= n; i++) {
            Arrays.fill(f[i], 0, n + 1, 0);
        }
        f[0][0] = 1;
        for (int i = 1; i <= n; i++) {
            if (s[i] == '(') {
                for (int j = 1; j <= n; j++) f[i][j] = f[i - 1][j - 1];
            } else {
                f[i][0] = (f[i - 1][1] + f[i - 1][0]) % P;
                for (int j = 1; j <= n; j++) {
                    f[i][j] = (f[i - 1][j + 1] + f[i][j - 1]) % P;
                }
            }
        }
        for (int i = 0; i <= n; i++) {
            if (f[n][i] > 0) return f[n][i];
        }
        return -1;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

